import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComplaintVO, ComplaintForm, ComplaintQuery } from '@/api/business/complaint/types';

/**
 * 查询投诉列表
 * @param query
 * @returns {*}
 */

export const listComplaint = (query?: ComplaintQuery): AxiosPromise<ComplaintVO[]> => {
  return request({
    url: '/business/complaint/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询投诉详细
 * @param id
 */
export const getComplaint = (id: string | number): AxiosPromise<ComplaintVO> => {
  return request({
    url: '/business/complaint/' + id,
    method: 'get'
  });
};

/**
 * 新增投诉
 * @param data
 */
export const addComplaint = (data: ComplaintForm) => {
  return request({
    url: '/business/complaint',
    method: 'post',
    data: data
  });
};

/**
 * 修改投诉
 * @param data
 */
export const updateComplaint = (data: ComplaintForm) => {
  return request({
    url: '/business/complaint',
    method: 'put',
    data: data
  });
};

/**
 * 删除投诉
 * @param id
 */
export const delComplaint = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/complaint/' + id,
    method: 'delete'
  });
};
